
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Creating a Universal Console</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<style type="text/css">
#demo .first button {
    margin-bottom: 2em;
}

#demo .yui3-console .yui3-console-title {
    border: 0 none;
    color: #000;
    font-size: 13px;
    font-weight: bold;
    margin: 0;
    text-transform: none;
}
#demo .yui3-console .yui3-console-entry-meta {
    margin: 0;
}

.clr {
    clear: both;
}
</style>

<!--end custom header content for this example-->

</head>

<body class="yui3-skin-sam  yui-skin-sam">

<h1>Creating a Universal Console</h1>

<div class="exampleIntro">
	<p>In this example, three YUI instances are created, each binding a button to call <code>Y.log(...)</code>.  Then an additional, separate YUI instance is created that requests only the <code>console</code> module and creates a Console that listens for log events from all three.</p>
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<div id="demo">
    <div class="yui-g">
        <div class="yui-u first">
            <h4>YUI #1</h4>
            <button type="button" id="yui1">Log from YUI instance #1</button>

            <h4>YUI #2</h4>
            <button type="button" id="yui2">Log from YUI instance #2</button>

            <h4>YUI #3</h4>
            <button type="button" id="yui3">Log from YUI instance #3</button>
        </div>
        <div class="yui-u" id="yconsole">
        </div>
    </div>
    <div class="clr"></div>
</div>
<script type="text/javascript">

// Create the first YUI instance
YUI({ filter: 'raw' }).use("node", function (Y) {
    
    Y.one( "#yui1" ).on( "click", function () {
        Y.log( "Message from YUI instance #1" );
    });

});

// Create the second YUI instance
YUI({ filter: 'raw' }).use("node", function (Y) {

    Y.one( "#yui2" ).on( "click", function () {
        Y.log( "I'm the second YUI instance" );
    });

});

// Create a third YUI instance
YUI({ filter: 'raw' }).use("node", function (Y) {

    Y.one( "#yui3" ).on( "click", function () {
        Y.log( "And this is #3 YUI" );
    });

});

// Create a separate YUI instance to listen to all instances' logging
YUI({ filter: 'raw' }).use("console", function (Y) {

    // Configure the Console's logSource to Y.Global to make it universal
    new Y.Console({
        logSource: Y.Global,
        style: 'block',
        newestOnTop: false,
        width: "250px"
    }).render( "#yconsole" );

});

</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
